/**
 * Created by zhangxiaoyu on 16/4/19.
 */
angular.module('hyt.scanCodeService',[])

    .factory('ScanCodeFactory',function($resource,$rootScope,ENV,Storage,$ionicLoading,$state){
        var api =  Storage.get('fwqdz');

        var resource = $resource(api);
        var result;

        return{
            cydsl : function(sid,yh_id,user_id,shbm_id,zcd_id){
                return resource.save({
                    "DataType":"yw",
                    "SID":sid,
                    "USER_ID":user_id,
                    'ACTION_NAME' : 'sqlKeyBiz.zcdList#zcd_query',
                    'ACTION_INFO' : {
                        'zcd_id': zcd_id,
                        'yh_id': yh_id,
                        'shbm_id':shbm_id
                    }
                },function(r){
                     if (r.ACTION_RETURN_CODE == "000005"){
                        $ionicLoading.show({
                            noBackdrop: true,
                            template: "您的账号已在其他设备登录",
                            duration: 1500
                        });
                        $state.go("login");
                    }
                    result=r.ACTION_INFO;
                    $rootScope.$broadcast('Cydsl.update');
                })
            },
            getResult:function(){
                return result;
            }
        }
    })
